package cn.chitanda.weather.data.db

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import cn.chitanda.weather.data.weather.Basic

@Database(entities = [Basic::class], version = 1)
abstract class PlaceDataBase : RoomDatabase() {
    abstract fun getPlaceDao(): PlaceDao

    companion object {
        private var instace: PlaceDataBase? = null
        fun getInstance(context: Context) = instace ?: synchronized(this) {
            Room.databaseBuilder(
                context.applicationContext,
                PlaceDataBase::class.java,
                "citylist"
            ).build().also {
                instace = it
            }
        }
    }
}
